<template>
  <el-dialog
    title="查看备注"
    :visible.sync="dialogVisible"
    width="1000px"
  >
    <el-table
      :data="tableData"
      border
    >
      <el-table-column
        label="备注信息"
        prop="remark"
      ></el-table-column>
      <el-table-column
        align="center"
        label="操作人员"
        prop="username"
        width="120"
      ></el-table-column>
      <el-table-column
        align="center"
        label="时间"
        prop="create_time"
      ></el-table-column>
    </el-table>
    <custom-page
      ref="customPage"
      :total="total"
      @getList="getList"
    ></custom-page>
    <div
      slot="footer"
      class="dialog-footer"
    >
      <el-button
        type="primary"
        @click="dialogVisible=false"
      >关闭</el-button>
      <el-button
        type="warning"
        @click="add"
      >添加备注</el-button>
    </div>
    <add-dialog
      ref="addDialog"
      :order-id="orderId"
      :which-period="whichPeriod"
      @getList="getList"
    ></add-dialog>
  </el-dialog>
</template>

<script>
import { getOrderRemark } from "@/api/finance";
import customPage from "@/components/customPage";
import addDialog from "./addRemark";
export default {
  props: ['orderId', 'whichPeriod'],
  components: { customPage, addDialog },
  data() {
    return {
      dialogVisible: false,
      tableData: [],
      total: 0
    };
  },
  methods: {
    add() {
      this.$refs.addDialog.dialogVisible = true;
    },
    getList() {
      const { page, pageSize } = this.$refs.customPage;
      getOrderRemark({
        page,
        pageSize,
        orderId: this.orderId
      }).then(res => {
        this.tableData = res.data || [];
        this.total = res.total;
      })
    }
  },
  watch: {
    dialogVisible(val) {
      if (val) {
        this.$nextTick(() => {
          this.getList();
        })
      }
    }
  }
};
</script>

<style lang="scss" scoped>
</style>